import java.util.ArrayList;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: zm
 * Date: 2023/4/3
 */
public class Demo11 {
    public static int miceAndCheese(int[] reward1,int[] reward2,int k){
        int n = reward1.length;
        int[] dp = new int[n];
        for(int i = 0; i < n; i++){
            dp[i] = reward1[i] - reward2[i];
        }
        int sum = 0;


        int index = 0;
        for(int i = 0; i < k; i++){
            int max = Integer.MIN_VALUE;
            for(int j = 0; j < n; j++){
                if(max < dp[j]){
                    max = dp[j];
                    index = j;
                }
                if(j == n - 1){
                    reward2[index] = 0;
                    dp[index] = Integer.MIN_VALUE + 1;
                }
            }

            sum += reward1[index];
        }
        for(int i = 0; i < n; i++){
            sum += reward2[i];
        }
        return sum;
    }
    public static List<List<Integer>> findMatrix(int[] nums) {
        ArrayList<List<Integer>> res = new ArrayList<>();
        int n = nums.length;
        ArrayList<Integer> list1 = new ArrayList();
        for(int i = 0; i < n; i++){
            list1.add(nums[i]);
        }


        while(!list1.isEmpty()){
            ArrayList list = new ArrayList<>();
            int i = 0;
            while(i != list1.size()){
                if(!list.contains(list1.get(i))){
                    list.add(list1.get(i));
                    list1.remove(i);
                }else{
                    i++;
                }
            }
//            for(int i = 0; i < n; i++){
//                if(!list.contains(list1.get(i))){
//                    list.add(list1.get(i));
//                    list1.remove(i);
//                }
//            }
            res.add(list);
        }

        return res;
    }
    public static void main(String[] args) {
        int[] array = new int[]{1,3,4,1,2,3,1};
        findMatrix(array);
    }
}
